﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ParentTest_child
{
    public partial class Form1 : Form
    {
        //[DllImport("user32.dll")]
        //private static extern IntPtr GetForegroundWindow();

        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
        
        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetParent(IntPtr hWndChild, int hWndNewParent);

        public Form1()
        {
            InitializeComponent();
            // get handle
            //IntPtr handle = GetForegroundWindow();
            // get title
           // const int count = 512;
           // var text = new StringBuilder(count);

          //  if (GetWindowText(handle, text, count) > 0)
          //  {
          //      Console.WriteLine(text.ToString());
          //  }
            SetParent(this.Handle, 1381250);
        }
    }
}
